<?php
class Zendvn_Filter_Utf8 implements Zend_Filter_Interface{
	
	public function filter($value){
		
		/*a Ã  áº£ Ã£ Ã¡ áº¡ Äƒ áº± áº³ áºµ áº¯ áº· Ã¢ áº§ áº© áº« áº¥ áº­ b c d Ä‘ e Ã¨ áº» áº½ Ã© áº¹ Ãª á»� á»ƒ á»… áº¿ á»‡
	      f g h i Ã¬ á»‰ Ä© Ã­ á»‹ j k l m n o Ã² á»� Ãµ Ã³ á»� Ã´ á»“ á»• á»— á»‘ á»™ Æ¡ á»� á»Ÿ á»¡ á»› á»£
	      p q r s t u Ã¹ á»§ Å© Ãº á»¥ Æ° á»« á»­ á»¯ á»© á»± v w x y á»³ á»· á»¹ Ã½ á»µ z*/
		/*$filter = new Zend_Filter_StringToLower('utf-8');
		$value = $filter->filter($value);*/
		
		  $charaterA = '#(Ã |áº£|Ã£|Ã¡|áº¡|Äƒ|áº±|áº³|áºµ|áº¯|áº·|Ã¢|áº§|áº©|áº«|áº¥|áº­)#imsU';
	      $replaceCharaterA = 'a';
	      $value = preg_replace($charaterA, $replaceCharaterA, $value);
      	
	      $charaterD = '#(Ä‘)#imsU';
	      $replaceCharaterD = 'd';
	      $value = preg_replace($charaterD,$replaceCharaterD,$value);
	      
	      $charaterE = '#(Ã¨|áº»|áº½|Ã©|áº¹|Ãª|á»�|á»ƒ|á»…|áº¿|á»‡)#imsU';
	      $replaceCharaterE = 'e';
	      $value = preg_replace($charaterE,$replaceCharaterE,$value);
	   
	      $charaterI = '#(Ã¬|á»‰|Ä©|Ã­|á»‹)#imsU';
	      $replaceCharaterI = 'i';
	      $value = preg_replace($charaterI,$replaceCharaterI,$value);
	      
	      $charaterO = '#(Ã²|á»�|Ãµ|Ã³|á»�|Ã´|á»“|á»•|á»—|á»‘|á»™|Æ¡|á»�|á»Ÿ|á»¡|á»›|á»£)#imsU';
	      $replaceCharaterO = 'o';
	      $value = preg_replace($charaterO,$replaceCharaterO,$value);
	            
	      $charaterU = '#(Ã¹|á»§|Å©|Ãº|á»¥|Æ°|á»«|á»­|á»¯|á»©|á»±)#imsU';
	      $replaceCharaterU = 'u';
	      $value = preg_replace($charaterU,$replaceCharaterU,$value);
	      
	      $charaterY = '#(á»³|á»·|á»¹|Ã½|á»µ)#imsU';
	      $replaceCharaterY = 'y';
	      $value = preg_replace($charaterY,$replaceCharaterY,$value);
	      
	      $charaterA = '#(à|ả|ã|á|ạ|ă|ằ|ẳ|ẵ|ắ|ặ|â|ầ|ẩ|ẫ|ấ|ậ)#imsU';
	      $replaceCharaterA = 'a';
	      $value = preg_replace($charaterA, $replaceCharaterA, $value);
	       
	      $charaterD = '#(đ|Đ)#imsU';
	      $replaceCharaterD = 'd';
	      $value = preg_replace($charaterD,$replaceCharaterD,$value);
	      
	      $charaterE = '#(è|ẻ|ẽ|é|ẹ|ê|ề|ể|ễ|ế|ệ)#imsU';
	      $replaceCharaterE = 'e';
	      $value = preg_replace($charaterE,$replaceCharaterE,$value);
	       
	      $charaterI = '#(ì|ỉ|ĩ|í|ị)#imsU';
	      $replaceCharaterI = 'i';
	      $value = preg_replace($charaterI,$replaceCharaterI,$value);
	      
	      $charaterO = '#(ò|ỏ|õ|ó|ọ|ô|ồ|ổ|ỗ|ố|ộ|ơ|ờ|ở|ỡ|ớ|ợ)#imsU';
	      $replaceCharaterO = 'o';
	      $value = preg_replace($charaterO,$replaceCharaterO,$value);
	      
	      $charaterU = '#(ù|ủ|ũ|ú|ụ|ư|ừ|ử|ữ|ứ|ự)#imsU';
	      $replaceCharaterU = 'u';
	      $value = preg_replace($charaterU,$replaceCharaterU,$value);
	      
	      $charaterY = '#(ỳ|ỷ|ỹ|ý|ỵ)#imsU';
	      $replaceCharaterY = 'y';
	      $value = preg_replace($charaterY,$replaceCharaterY,$value);
      
		return $value;
	}
}